package geekstudy.week1;

/**
 *
 * 83. 移动零
 * https://leetcode-cn.com/problems/move-zeroes/
 *
 *
 */
public class Week1MoveZeroes {


    public void moveZeroes(int[] nums) {
        for(int size = 0; size < nums.length; size++) {
            int sizeValue = nums[size];
            if(sizeValue == 0) {
                for(int nextSize = size + 1; nextSize < nums.length; nextSize++) {
                    int nextValue = nums[nextSize];
                    if(nextValue != 0) {
                        nums[size] = nums[nextSize];
                        nums[nextSize]= 0;
                        break;
                    }
                }
            }
        }
    }




    public void forward(int[] array, int index) {
        for(int size = index; size < array.length - 1; size++) {
            array[size] = array[size + 1];
        }
        array[array.length - 1] = 0;
    }

    public static void main(String[] args) {

    }

}
